package com.suitsoft.ut.dao.base;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springside.modules.orm.hibernate.HibernateDao;

import com.suitsoft.ut.entity.base.TeacherTemp;

/**
 * 
 *@author Suine
 */
@Repository
public class TeacherTempDao extends HibernateDao<TeacherTemp,Long>{
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private JdbcTemplate jdbcTemplate; 
	
	public void deleteAll(){
		String hql = "delete TeacherTemp where 1=1";
		batchExecute(hql);
	}
	
	public List<Map<String,Object>> getImpList(){
//		String sql = "SELECT TT.COLLEGE,COUNT(*) C FROM LW_TEACHER_TEMP  TT GROUP BY TT.COLLEGE ORDER BY TT.COLLEGE";
		StringBuffer sb = new StringBuffer();
		sb.append(" SELECT A.COLLEGE,COUNT(*) C,SUM(D) D,COUNT(*) - SUM(D) ND FROM (SELECT TT.*,DECODE(TT.IS_CONFIRM,NULL,0,1) D ");
		sb.append(" FROM LW_TEACHER_TEMP TT) A GROUP BY A.COLLEGE ");
		return jdbcTemplate.queryForList(sb.toString());
	}

}

